﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GregsList.Models;
namespace GregsList.Controllers
{
    public class HomeController : Controller
    {
        List<Post> posts = new List<Post>() { 
            new Post("ERROR","ERROR","ERROR",0),
            new Post("Drum Set For Sale", "Brand New Drum Set","Selling Item", 1),
            new Post("Coder For Rent","9 week bootcamp come join","Services",2),
            new Post("I Eat For You","If you have leftover food call me. I will finish it","Services",3),
            new Post("Help","Call 911","Emergency",4),
            new Post("Whats Wrong?", "I am 911. Here to help","Services",2)
        };
        List<User> users = new List<User>()
        {
            new User("ERROR", "ERROR"),
            new User("Dean","yahoo.com"),
            new User("Son","bing.com"),
            new User("Paul","hotmail.com"),
            new User("Josh", "gmail.com")
        };
        

        public ActionResult Index()
        {
            return View(posts);
        }
        public ActionResult PostDetail()
        {
            PostDetail pd = new PostDetail(posts[0],users[0]);
            int findPost = 3;
            for(int i = 0; i<users.Count -1;i++ ){
                if(posts[findPost].PosterID == users[i].UserID){
                    //pd = new PostDetail(posts[findPost],users[i]);
                    pd.SingleUser = users[i];
                    pd.SinglePost = posts[findPost];
                    Console.Write("success in for loop");
                }
            }
            return View(pd);
        }
        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}